#monkey patching
import sys
import os
sys.path.insert(0, os.getcwd())

BROKER_HOST = "127.0.0.1"
BROKER_USER = "crane"
BROKER_PASSWORD = "cr@nepassw0rd"
BROKER_VHOST = "/"

#Routing stuff
CELERY_QUEUES = {
    
    "auto": {
        "exchange": "auto",
        "exchange_type": "direct",
        "binding_key": "auto"
    },
    
    "hust": {
        "exchange": "hust",
        "exchange_type": "direct",
        "binding_key": "hust"
    },

#    "tsinghua": {
#        "exchange": "tsinghua",
#        "exchange_type": "direct",
#        "binding_key": "tsinghua"
#    }
}

#CELERY_CREATE_MISSING_QUEUES = True

CELERY_DEFAULT_QUEUE = "auto"
CELERY_DEFAULT_EXCHANGE = "auto"
CELERY_DEFAULT_EXCHANGE_TYPE = "direct"
CELERY_DEFAULT_ROUTING_KEY = "auto"



## modules to import
#CELERY_IMPORTS = ("webapi", "mon_getter", "iaas", "mpiapi")
CELERY_IMPORTS = ("webapi", "mon_getter", "iaas", "mpiapi")

CELERY_RESULT_BACKEND = "amqp"
CELERY_AMQP_TASK_RESULT_EXPIRES = 18000 #5 hours, require RabbitMQ 2.1.0 if using amqp backend
CELERY_RESULT_PERSISTENT = True

#CELERY_RESULT_BACKEND = "cache"
#CELERY_CACHE_BACKEND = 'memcached://202.114.10.145:11211'
#;10.10.0.2:11211;10.10.0.3:11211;10.10.0.4:11211;10.10.0.5:11211;10.10.0.6:11211;10.10.0.7:11211;10.10.0.8:11211;10.10.0.9:11211'
#CELERY_CACHE_BACKEND_OPTIONS = {"binary": True, "behaviors": {"tcp_nodelay": True}}

## worker settings
CELERYD_CONCURRENCY = 8
CELERYD_PREFETCH_MULTIPLIER = 16 # small is better for balancing long-running tasks.
CELERYD_MAX_TASKS_PER_CHILD = 1024


## tracking tasks
CELERY_TRACK_STARTED = True
CELERY_SEND_EVENTS =True



## email reporting
CELERY_SEND_TASK_ERROR_EMAILS = False

# Name and e-mail addresses of recipients
ADMINS = (
    ("Bo Xiao", "mail.xiaobo@gmail.com"),
)

# E-mail address used as sender (From field).
SERVER_EMAIL = "mail.xiaobo@gmail.com"

# Mailserver configuration
#EMAIL_HOST = "smtp.gmail.com"
#EMAIL_PORT = 25
# EMAIL_HOST_USER = "servers"
# EMAIL_HOST_PASSWORD = "s3cr3t"
print "Celery is properly configured."
